<%--
  Created by IntelliJ IDEA.
  User: wonderming
  Date: 2018/4/17
  Time: 18:54
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<div class="modal-header">
    <button class="close" ng-click="cancel()">
        <span aria-hidden="true">×</span>
    </button>
    <h3 class="modal-title" id="modal-title">风控限次管理</h3>
</div>

<div class="modal-body" id="modal-body">
    <div class="ibox-content no-borders tab-content">
        <!--添加-->
        <form name="myForm" class="form-horizontal formTopSpacing" ng-model="indefinitely" ng-show="type == 0 ">
            <!-- 类型 -->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>类型：</label>
                <div class="col-sm-8">
                    <select id="type" name="type" class="form-control" ng-model="indefinitely.refType"
                            ng-blur="typeBlur($event,indefinitely.refType)" required>
                        <option value=""></option>
                        <option value="0">通用</option>
                        <option value="1">收单机构</option>
                        <option value="2">商户</option>
                        <option value="3">域名</option>
                    </select>
                </div>
            </div>
            <!-- 名称-->
            <div class="form-group" ng-show="indefinitely.refType != 0 && indefinitely.refType !=  1 && indefinitely.refType != 2 && indefinitely.refType != 3">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>名称：</label>
                <div class="col-sm-8">
                    <select name="name" class="form-control" ng-model="indefinitely.refId"
                            ng-blur="nameBlur($event,indefinitely.refId)" required>
                        <option  ng-value=""></option>
                    </select>
                </div>
            </div>
            <div class="form-group" ng-show="indefinitely.refType == 0 ">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>名称：</label>
                <div class="col-sm-8">
                    <select name="name" class="form-control" ng-model="indefinitely.refId" ng-blur="nameBlur($event,indefinitely.refId)" required>
                        <option  ng-value="0">
                            通用
                        </option>
                    </select>
                </div>
            </div>
            <div class="form-group" ng-show="indefinitely.refType == 1">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>名称：</label>
                <div class="col-sm-8">
                    <select  name="name" class="form-control" ng-model="indefinitely.refId"
                             ng-blur="nameBlur($event,indefinitely.refId)" required>
                        <option  ng-repeat="x in init.acquirer" ng-value="x.id">
                        {{ x.name }}
                        </option>
                    </select>
                </div>
            </div>
            <div class="form-group" ng-show="indefinitely.refType == 2">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>名称：</label>
                <div class="col-sm-8">
                    <select name="name" class="form-control" ng-model="indefinitely.refId"
                            ng-blur="nameBlur($event,indefinitely.refId)" required>
                        <option  ng-repeat="x in init.merchant" ng-value="x.id">
                        ({{ x.id }}) {{ x.name }}
                        </option>
                    </select>
                </div>
            </div>
            <div class="form-group" ng-show="indefinitely.refType == 3">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>名称：</label>
                <div class="col-sm-8">
                    <select name="name" class="form-control" ng-model="indefinitely.refId"
                            ng-blur="nameBlur($event,indefinitely.refId)"  required>
                        <option ng-repeat="x in init.siteurl" ng-value="x.id">
                        {{ x.siteUrl }}
                        </option>
                    </select>
                </div>
            </div>
            <!-- 限制元素-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>限制元素：</label>
                <div class="col-sm-8">
                    <select id="limit" name="limit" class="form-control" ng-model="indefinitely.element"
                            ng-blur="limitBlur($event,indefinitely.element)" required>
                        <option value=""></option>
                        <option ng-repeat="x in init.limitConstant" value="{{ x.id }}">
                            {{ x.name }}
                        </option>
                    </select>
                </div>
            </div>
            <!-- 允许成功次数-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>允许成功次数：</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="success" ng-model="indefinitely.elementValue" ng-keyup="successBlur($event,indefinitely.elementValue)" required>
                </div>
            </div>
            <!--允许失败次数-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>允许失败次数：</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="fail" ng-model="indefinitely.elementFailValue" ng-keyup="failBlur($event,indefinitely.elementFailValue)" required>
                </div>
            </div>
            <!-- 单位小时-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>单位:小时:</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="hour" ng-model="indefinitely.ctyle" ng-keyup="hourBlur($event,indefinitely.ctyle)" required>
                </div>
            </div>
            <!-- 状态-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>状态:</label>
                <div class="col-sm-8">
                    <select  name="status" class="form-control" ng-model="indefinitely.status" ng-blur="statusBlur($event,indefinitely.status)" required>
                        <option value=""></option>
                        <option value="1">启用</option>
                        <option value="0">禁用</option>
                    </select>
                </div>
            </div>
        </form>
        <!--更新-->
        <form name="myFormupdate" class="form-horizontal formTopSpacing" ng-model="risk" ng-show="type == 1">
            <!--类型-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>类型：</label>
                <div class="col-sm-8">
                    <select name="typeupdate" class="form-control" ng-model="risk.refType"
                            ng-blur="typeupdateFocus($event,risk.refType)" required>
                        <option value=""></option>
                        <option value="0">通用</option>
                        <option value="1">收单机构</option>
                        <option value="2">商户</option>
                        <option value="3">域名</option>
                    </select>
                </div>
            </div>
            <!-- 名称-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span class="text-danger">*</span>名称: </label>
                <div class="col-sm-8">
                    <select name="nameupdate" class="form-control" ng-model="risk.refId" ng-blur="nameupdateFocus($event,risk.refId)" required>
                        <option ng-repeat="x in initParam" ng-value="x.id">
                            {{ x.name != undefined ? x.name : x.siteUrl }}
                        </option>
                    </select>
                </div>
            </div>
            <!-- 限制元素-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>限制元素：</label>
                <div class="col-sm-8">
                    <select  name="limitupdate" class="form-control" ng-model="risk.element"
                             ng-blur="limitupdateFocus($event,risk.element)" required>
                        <option value=""></option>
                        <option ng-repeat="x in init.limitConstant" value="{{ x.id }}">
                            {{ x.name }}
                        </option>
                    </select>
                </div>
            </div>
            <!-- 允许成功次数-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>允许成功次数：</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="successupdate" ng-model="risk.elementValue" ng-keyup="successupdateBlur($event,risk.elementValue)" required>
                </div>
            </div>
            <!-- 允许失败次数-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>允许失败次数：</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="failupdate" ng-model="risk.elementFailValue" ng-keyup="failupdateBlur($event,risk.elementFailValue)" required>
                </div>
            </div>
            <!-- 单位小时-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>单位:小时:</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="hourupdate" ng-model="risk.ctyle" ng-keyup="hourupdateBlur($event,risk.ctyle)" required>
                </div>
            </div>
            <!-- 状态-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>状态:</label>
                <div class="col-sm-8">
                    <select name="statusupdate" class="form-control" ng-model="risk.status" ng-blur="statusupdateBlur($event,risk.status)" required>
                        <option value=""></option>
                        <option value="1">启用</option>
                        <option value="0">禁用</option>
                    </select>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="modal-footer">
    <row>
        <div class="col-sm-12">
            <div class="center">
                <button class="btn btn-sm btn-primary general-btn" type="button"
                        ng-click="insertRiskLimit(indefinitely,0)"
                        ng-disabled="!myForm.type.$valid || !myForm.name.$valid || !myForm.limit.$valid || !myForm.success.$valid || !myForm.fail.$valid || !myForm.hour.$valid || !myForm.status.$valid"
                        ng-show="type == 0">
                    确定
                </button>
                <button class="btn btn-sm btn-primary general-btn" type="button" ng-click="updateRiskLimit(risk,1)"
                        ng-disabled="nextDisabled(myFormupdate)"
                        ng-show="type == 1">
                    确定
                </button>
            </div>
        </div>
    </row>
</div>